﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using seo.Data;
using seo.DAO;
using MySql.Data.MySqlClient;
using seo.dbutils;

namespace seo.Buz
{
    public class KeywordBuz
    {
        public List<Keyword> getAllKeyword() {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            List<Keyword> list = null;
            try
            {
                conn.Open();
                KeywordDao dao = new KeywordDao(conn);
                list = dao.getAllKeyword();
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally {
                conn.Close();
            }

            return list;
        
        }

        public int getTotalKeywordWeight(int siteid)
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            int totalkeywordweight = 0;
            try
            {
                conn.Open();
                KeywordDao dao = new KeywordDao(conn);
                totalkeywordweight = dao.getTotalKeywordWeight(siteid);

            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return totalkeywordweight;

        }

        public List<Keyword> getKeywordListBySiteId(int siteid)
        {
            MySqlConnection conn = dbConnection.getLocalDbConnection();
            List<Keyword> list = null;
            try
            {
                conn.Open();
                KeywordDao dao = new KeywordDao(conn);
                list = dao.getKeywordListBySiteId(siteid);

            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return list;

        }

    }
}
